package com.arvin.mapper;

import com.arvin.pojo.Exempt;
import com.arvin.pojo.Interview;
import com.arvin.pojo.IntvInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface InterviewMapper {


    /**
     * 保存面试信息
     * @param interview1
     */
    void saveInterviewInfo(Interview interview1);

    /**
     * 通过id获取面试信息
     * @param intvId
     * @return
     */
    @Select("select * from t_interview where intv_id = #{intvId} ")
    Interview findByIntvId(Integer intvId);

    /**
     * 获取面试信息
     * @param studentId
     * @param intvDate
     * @param stuName
     * @param className
     * @param intvState
     * @param intvScore
     * @return
     */
    List<IntvInfo> getIntvInfo(String studentId, LocalDate intvDate,
                               String stuName,String className,
                               String intvState,Integer intvScore);

    /**
     * 删除面试信息
     * @param intvId
     */
    @Delete("delete from t_interview where intv_id = #{intvId} ")
    void deleteIntv(Integer intvId);

    /**
     * 修改学生面试状态
     * @param interview
     */
    void updateIntvInfo(Interview interview);

    /**
     * 学生批量通过获不通过考试
     * @param ids
     */
    void updateStateByIntvIds(List<Integer> ids,String intvState);

    /**
     * 通过考试日期获取预约面试时间信息
     * @param intvDate
     * @param studentId
     * @return
     */
    @Select("select * from t_interview " +
            "where intv_date between #{intvDate} and #{intvDate} " +
            "and student_id != #{studentId}")
    List<Interview> findByIntvDate(LocalDate intvDate,String studentId);

    /**
     * 通过免试日期获取预约免试时间信息
     * @param exemDate
     * @param studentId
     * @return
     */
    @Select("select * from t_exempt " +
            "where exem_date between #{exemDate} and #{exemDate} " +
            "and student_id != #{studentId}")
    List<Exempt> findByExemDate(LocalDate exemDate, String studentId);

    /**
     * 通过面试id清除面试信息
     * @param intvId
     */
    @Update("update t_interview set intv_date = null,intv_time = null," +
            "intv_state = '',intv_score = null,update_time = now() " +
            "where intv_id = #{intvId}")
    void clearByIntvId(Integer intvId);
}
